package com.itheima.TimeAspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@Aspect
public class Time {


    @Around("execution(* com.itheima.service.*.*(..))")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
         long begin = System.currentTimeMillis();
         Object proceed = pjp.proceed();
         long end = System.currentTimeMillis();
       log.info(pjp.getSignature()+"耗时:{} ms",end-begin);

       return proceed;
    }
}
